# Contributor: Bartłomiej Piotrowski <bpiotrowski@archlinux.org>
# Contributor: Rafael Ferreira <josephgbr@archlinux.info>

pkgname=lucene++
pkgver=3.0.8
_githash='972c9cb37'
pkgrel=6
pkgdesc='C++ port of the popular Java Lucene library'
arch=(loong64 x86_64)
url='https://github.com/luceneplusplus/LucenePlusPlus'
license=('GPL' 'Apache')
depends=('boost-libs')
makedepends=('boost' 'cmake' 'subversion')
#source=(https://github.com/luceneplusplus/LucenePlusPlus/archive/rel_$pkgver.tar.gz)
source=("https://github.com/luceneplusplus/LucenePlusPlus/archive/${_githash}.tar.gz")
sha512sums=('1c53533ea159a06f3cfff441449a895aa59580a028ad21e1e339fce9b99f7226710759d8d9b527cd604836149c194375fa35b4bb1d9d3ca112fbcb81555d8d8f')

prepare() {
  mkdir build
  #ln -s LucenePlusPlus-rel_$pkgver LucenePlusPlus-$pkgver
  #ln -s LucenePlusPlus-master LucenePlusPlus-$pkgver
  ln -s LucenePlusPlus-$_githash* LucenePlusPlus-$pkgver
  sed -i \
    -e 's#SET(LUCENE++_VERSION_REVISION.*#SET(LUCENE++_VERSION_REVISION "5")#' \
    -e 's#SET(LUCENE++_VERSION_PATCH.*#SET(LUCENE++_VERSION_PATCH "0")#' \
    "$srcdir"/LucenePlusPlus-$pkgver/CMakeLists.txt
}

build() {
  cd build

  cmake ../LucenePlusPlus-$pkgver \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DLIB_DESTINATION=/usr/lib \
    -DBoost_LIBRARY_DIR=/usr/lib \
    -DENABLE_CUSTOM_ALLOCATOR='FALSE' \
    -DCMAKE_CXX_FLAGS='-DBOOST_VARIANT_USE_RELAXED_GET_BY_DEFAULT'
    # RELAXED for boost 1.58 breakage, remove when lucene++ updates

  make
}

package() {
  cd build
  make DESTDIR="$pkgdir" install
}
